home *** CD-ROM | disk | FTP | other *** search
- {$G+}
- { Just a small example of the well known fire effect. }
-
- uses crt;
-
- var ch : char;
- fire : array[1..41,0..41] of byte;
- i,j,k : integer;
-
- Procedure SetColor ( Color, Red, Green, Blue : Byte );
- Begin { SetColor }
- Port[$3C8] := Color;
- Port[$3C9] := Red;
- Port[$3C9] := Green;
- Port[$3C9] := Blue;
- end; { SetColor }
-
- begin
- writeln(' UNICORN UTM 1994 presents:');
- writeln(' A little fire effect by SHARP....');
- delay(500);
- asm
- mov ax,13h
- int 10h
- end;
- randomize;
- { calculate your starting values...}
- fillchar(fire,sizeof(fire),0);
- for i:=0 to 41 do begin
- { Hmm... well the maximum is 31.. does seem nice doesn't it:-)
- I split this in a random and constant value, this will change
- the effect in the way that you won't start with dark colors...
- Try some values for yourself aslong as they add up to the maximum
- colors you are using...}
- fire[41,i]:=random(21)+10;
- end;
- for i:=1 to 10 do begin
- { goin' from black to dark-gray to red to yellow, gives a nice effect..
- I've only used 31 colors here because of my future use for this code,
- You will probable be able to change this to 256... Then again if you
- can't... STOP READING THIS AND STOP CODING!!! or get a good book that
- expleans how to find the answer to 256 / 31 just to start with...}
- setcolor(i,i*1,i*1,i*1);
- setcolor(i+10,10+i*5,10,10);
- setcolor(i+20,63,10+i*5,10);
- end;
- repeat
- for i:=1 to 40 do begin
- for j:=1 to 40 do begin
- { O.K. the princeple is to calculate the average of a couple of points
- below your now point and put it into the buffer... I doubled the
- mid-point to add some extra effect, try some compinations for yourself...
- You could also use some points on the line above or equal but you
- will have to make a second buffer to copy the result in!!}
- fire[i,j]:=(fire[i+1,j-1]+(fire[i+1,j] shl 1)+fire[i+1,j+1]) shr 2;
- end;
- end;
- for i:=1 to 40 do begin
- for j:=1 to 40 do begin
- { ofcource for speed you could use the screen as your buffer so
- you will be able to skip this.. but do remind yourself that
- the screen memory is SLOW!! so it could also slow it down depending
- on the size of your fire!! Again try which works best for you...}
- mem[$a000:(80*320+120)+(i*320)+j]:=fire[i,j];
- end;
- end;
- { add a new line... }
- for i:=0 to 41 do begin
- { Well if you've figured out how to use more colors don't forget
- to change these values too!! You also probable noticed that
- i've used diferent values that with the last random function...
- This just changes the effect a little... Again this adds up to 31.
- Just experiment with it....}
- fire[41,i]:=random(26)+5;
- end;
- until keypressed;
- ch:=readkey;
- asm
- mov ax,3h
- int 10h
- end;
- end.
-
- { Simpel eh.... Amazing that a simple technice can produce an effect like
- this, but that's mostly the case. Well this code is highly unoptimized but
- I'll let you do that:-)... I wanne thank Phil Carlisle for telling me the
- princeple of the fire effect... All credits for the initial idea go to
- Jare (atleast as far as I know he did this first....)
-
- See Ya l8r, SHARP }
-